<?php

namespace App\Http\Requests;

use App\Http\Requests\BaseFormRequest;

class CompanyRequest extends BaseFormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    public function scenes()
    {
        return [
            'store'=>[
				'Co_Name'=>'required|max:150',
			],
			'update'=>[
				'Co_Name'=>'required|max:150',
			]
        ];
    }
	
	public function messages()
    {
        return [
			'Co_Name.required' => '公司名称必须',
			'Co_Name.max' => '公司名称不能超过150个字符',
			'is_default.unique' => '默认项目已经设置',
        ];
    }
	
	public function withValidator($validator)
	{
		$validator->sometimes('is_default', 'unique:t_companycnfo,is_default,'.$this->input('Co_ID').',Co_ID', function($input){
            return $input->is_default;
        });

	}
}
